# # CMakeLists.txt 直接包含头文件和源文件，文件结构为 ./src/*.c   ./inc/*.h   ./src/main.cpp
# cmake_minimum_required(VERSION 3.0.0)
# project(linklist)

# aux_source_directory(./src LIB_SRC)
# # 下面的语句和上面的语句意思应该是一致的
# # set(SOURCES 
# #     src/Linklist.c
# #     src/base64.c
# #     src/main.cpp
# # )
# add_executable(linklist ${LIB_SRC})
# # add_executable(linklist main.cpp ${LIB_SRC})

# target_include_directories(linklist  PRIVATE  ${PROJECT_SOURCE_DIR}/inc )
##############################################################################

# CMakeLists.txt 编译静态库，文件结构为 ./src/*.c   ./inc/*.h   ./main.cpp
cmake_minimum_required(VERSION 3.1)
project(hello)
aux_source_directory(./src LIB_SRC)
# 生成静态库，Mylib和路径之间不加其他命令表示STATIC
add_library(Mylib ${LIB_SRC})
target_include_directories(Mylib PUBLIC ${PROJECT_SOURCE_DIR}/inc) # 设置公有main.cpp才能引用头文件

add_executable(hello main.c)
target_link_libraries(hello Mylib)
##############################################################################

# # CMakeLists.txt 使用静态库编译，文件结构为 ./src/*.c   ./inc/*.h   ./main.cpp 
# cmake_minimum_required(VERSION 3.1)
# project(hello)
# aux_source_directory(./src LIB_SRC)
# # 静态库的地址
# link_directories(./static_lib)
# # 包含路径，不能使用target_include_directory,因为这不属于构建hello时的
# include_directories(${PROJECT_SOURCE_DIR}/inc)
# add_executable(hello main.cpp)
# target_link_libraries(hello Mylib)   # 库名称不用加lib
